import copy

print("list自带的copy()是浅拷贝".center(30, "#"))
source_list = list(range(10))
source_list.insert(5, ['apple', 'banana', 'candy', 'desert'])
shallow_copy_list = source_list.copy()
# 修改末尾的元素
source_list[-1] = 99
source_list[5][0] = 'apple_apple'
shallow_copy_list[-2] = 888
print('source_list:{0},id:{1},index_5:{2}'.format(source_list, id(source_list), id(source_list[5])))
print('shallow_copy_list:{0},id:{1},index_5:{2}'.format(shallow_copy_list, id(shallow_copy_list),
                                                        id(shallow_copy_list[5])))
print("深拷贝需要import copy".center(30, "#"))
deep_copy_list = copy.deepcopy(source_list)
source_list[5][1] = 'banana_banana'
print('source_list:{0},id:{1},index_5:{2}'.format(source_list, id(source_list), id(source_list[5])))
print('shallow_copy_list:{0},id:{1},index_5:{2}'.format(shallow_copy_list, id(shallow_copy_list),
                                                        id(shallow_copy_list[5])))
print('deep_copy_list:{0},id:{1},index_5:{2}'.format(deep_copy_list, id(deep_copy_list), id(deep_copy_list[5])))

print("深拷贝[:]".center(30, "#"))
deep_copy_list = source_list[:]
source_list[5] = 5
print('source_list:{0}'.format(source_list))
print('deep_copy_list:{0}'.format(deep_copy_list))
